fix(oidc): skip UserInfo endpoint call for Entra ID compatibility#171
Merged
Conversation
Entra's discovered UserInfo endpoint (graph.microsoft.com/oidc/userinfo) returns HTTP 200 but omits preferred_username, causing Spring Security's DefaultOAuth2UserService to throw before the ID token claims are merged. All required claims (preferred_username, groups) are present in the Entra v2.0 ID token when the profile scope is requested. Skip the UserInfo call entirely via setRetrieveUserInfo(req -> false). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace the unconditional setRetrieveUserInfo(req -> false) with a per-registration config flag (auth.oidc.skip-user-info, default false). When true, all claims are read from the ID token and the UserInfo endpoint is never contacted. Required for Entra ID, whose discovered UserInfo endpoint (graph.microsoft.com/oidc/userinfo) returns HTTP 200 but omits preferred_username — a Microsoft design constraint present on all Entra tenants. Standard OIDC providers (Keycloak, Okta, Dex) are unaffected by default. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
graph.microsoft.com/oidc/userinfo) returns HTTP 200 but omitspreferred_username, causingDefaultOAuth2UserServiceto throw before ID token claims are mergedpreferred_username cannot be null500 error on OIDC callbackpreferred_username,groups) are present in the Entra v2.0 ID token with theprofilescope — skip the UserInfo call entirely viasetRetrieveUserInfo(req -> false)Test plan
private_key_jwtclient authpreferred_usernameandgroupsclaims are populated from ID tokengroupsclaim still works (ROLE_ADMIN granted via group membership)🤖 Generated with Claude Code